package com.friend.controller.exam;

import com.common.core.controller.BaseController;
import com.common.core.domain.Result;
import com.common.core.domain.TableDataInfo;
import com.friend.domain.exam.dto.ExamQueryDTO;
import com.friend.domain.exam.dto.ExamRankDTO;
import com.friend.service.exam.ExamService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
@Tag(name = "竞赛管理API")
public class ExamController extends BaseController {
    @Resource
    ExamService examService;

    /**
     * 获取竞赛列表
     *
     */
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return getTableData(examService.list(examQueryDTO));
    }

    /**
     * 获取竞赛列表（使用Redis缓存）
     *
     */
    @GetMapping("/semiLogin/redis/list")
    public TableDataInfo redisList(ExamQueryDTO examQueryDTO){
        return examService.redisList(examQueryDTO);
    }

    /**
     * 获取竞赛首题
     *
     */
    @GetMapping("/getFirstQuestion")
    public Result<String> getFirstQuestion(Long examId){
        return Result.success(examService.getFirstQuestion(examId));
    }

    /**
     * 获取上一题
     *
     */
    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long examId, Long questionId){
        return Result.success(examService.preQuestion(examId,questionId));
    }

    /**
     * 获取下一题
     *
     */
    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long examId, Long questionId){
        return Result.success(examService.nextQuestion(examId,questionId));
    }

    /**
     * 获取竞赛排名
     *
     */
    @GetMapping("/rank/list")
    public TableDataInfo rankList(ExamRankDTO examRankDTO){
        return examService.rankList(examRankDTO);
    }
}
